﻿using System;
using Demo.CommonBase.View.Controllers;
using Demo.CommonBase.View.Contracts;
using Demo.CommonBase.Logging;
using Demo.CommonBase.Exceptions;
using System.Reflection;
using Demo.Services.Services.Impl.Managers;
using System.Collections.Generic;
using Demo.Services.Contracts.DTO.Infos;


namespace Demo.Services.View.Controllers
{
    public sealed class DemoController : AbstractDemoController
    {
        protected override void ConcreteExecute(IView view, string action)
        {
            try
            {
                switch (action)
                {
                    case "Services.GetContacts":
                        GetContacts(view);
                        break;
                    default: break;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }



        private void GetContacts(IView view)
        {
            DemoManager demoManager;
            IList<ContactInfo> contactos;
            try
            {
                demoManager = new DemoManager();
                contactos = demoManager.GetContactos();
                view.SetValue("Contactos", contactos);

            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
        }        
    }
}